package com.my.trace;

import android.location.Location;
import android.util.Log;

import java.util.ArrayList;

/**
 * Created by vic on 11/18/13.
 */
public class TrackPoints{
    final String TAG = "TrackPoints";
    //
    public static byte VAL_LATITUDE = 0;
    public static byte VAL_LONGITUDE = 1;
    public static byte VAL_ALTITUDE = 2;
    public static byte VAL_SPEED = 3;
    //
    ArrayList arrayList;
    //
    public TrackPoints(){
        arrayList = new ArrayList();
    }
    //
    public void addPoint(Location location){
        arrayList.add(location);

        //lattitude = location.getLatitude();
        //longitude = location.getLongitude();
        //altitude = location.getAltitude();
        //speed = location.getSpeed();
    }
    //
    public Location[] getLocations(int start, int size){
        if(size < arrayList.size())  size = arrayList.size();
        //
        Log.d(TAG, "getLocations " + size );
        //
        Location[] location = new Location[size];

        for(int i=0; i<size; i++){
            location[i] = (Location)arrayList.get(start+i);
        }
        //Location[] location = (Location[])arrayList.toArray(new Location[arrayList.size()]);
        //location.
        return location;
    }
    //
    public double getVal(int nValType, int idx){
        if(idx >= arrayList.size())  return 0;
        //
        Log.d(TAG, "getVal " + arrayList.size() );
        //
        Location location = (Location)arrayList.get(idx);

        if(nValType == VAL_LATITUDE)  return location.getLatitude();
        else if(nValType == VAL_LONGITUDE)  return location.getLongitude();
        else if(nValType == VAL_ALTITUDE)  return idx*10;//location.getAltitude();
        else if(nValType == VAL_SPEED)  return location.getSpeed();
        else  return 0;
    }
    //
    public int getSize(){
        return arrayList.size();
    }

}
